package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
//流对象获取数据
@WebServlet("/servletDemo6")
public class servletDemo6 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //字符流
        //对于表单流获取的数据只有post请求才能读取到
        BufferedReader br = req.getReader();
        String line;
        while ((line=br.readLine())!=null){
            System.out.println(line);
        }
        //对象获取出来的流不需要关闭
        //br.close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
